﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text

Public Class suspeicaoDAO

    Dim sql As New StringBuilder
    Dim objConn As New conexao
    Dim i As Integer
    Dim suspeicao As New suspeicaoVO

    Public Function getSuspeicoes() As Generic.List(Of suspeicaoVO)

        sql.Clear()
        sql.Append("SELECT *FROM SUSPEICAO ORDER BY DESC_SUSPEICAO")

        Dim oReader As OleDbDataReader
        Dim lista As New Generic.List(Of suspeicaoVO)

        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read

                suspeicao = New suspeicaoVO
                suspeicao.ID_SUSPEICAO = oReader("ID_SUSPEICAO")
                suspeicao.DESC_SUSPEICAO = oReader("DESC_SUSPEICAO")
                suspeicao.STATUS = oReader("STATUS")
                lista.Add(suspeicao)


            End While

            Return lista

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function



    Public Function getSuspeicao(ByVal id_suspeicao As Integer) As suspeicaoVO

        sql.Clear()
        sql.Append("SELECT *FROM SUSPEICAO WHERE ID_SUSPEICAO=" & id_suspeicao)

        Dim oReader As OleDbDataReader
        Dim lista As New Generic.List(Of suspeicaoVO)

        Try
            Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao)

            oReader = oComando.ExecuteReader

            While oReader.Read


                suspeicao = New suspeicaoVO
                suspeicao.ID_SUSPEICAO = oReader("ID_SUSPEICAO")
                suspeicao.DESC_SUSPEICAO = oReader("DESC_SUSPEICAO")
                suspeicao.STATUS = oReader("STATUS")

            End While

            Return suspeicao

        Catch ex As Exception

            Throw ex

        Finally

            objConn.fechaConexao()

        End Try

    End Function

End Class
